package com.agent.service.impl;

import com.agent.entity.PicWord;
import com.agent.page.EasyuiPage;
import com.agent.repository.PicWordMapper;
import com.agent.service.IPicWordService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


@Service("picWordService")
@Transactional
public class PicWordServiceImpl implements IPicWordService{
	
	@Autowired
	protected PicWordMapper picWordMapper;

	public void delete(String id) {
		picWordMapper.delete(id);
		
	}

	public List<PicWord> getPicWordList(PicWord picWord) {
		return picWordMapper.searchPicWord(picWord);
	}
	
	public PicWord getPicWord(String id) {
		List<PicWord> list = picWordMapper.getPicWord(id);
		return list==null||list.size()==0l?null:list.get(0);
	}

	public void insert(PicWord picWord) {
		picWordMapper.insert(picWord);
		/*picWord.setUpdator("123");
		picWordMapper.update(picWord);
		int i = 1/0;*/
	}

	public List<PicWord> searchAll() {
		return picWordMapper.searchAll();
	}

	public EasyuiPage<PicWord> searchPicWord(Integer page, Integer rows, PicWord picWord) {
		PageHelper.startPage(page, rows,true, true, true);
		List<PicWord> list = picWordMapper.searchPicWord(picWord);
		EasyuiPage<PicWord> pages = new EasyuiPage<PicWord>();
		pages.setRows(list);
		PageInfo<PicWord> pageinfo = new PageInfo<PicWord>(list);
		pages.setTotal(pageinfo.getTotal());
		return pages;
	}

	public void update(PicWord PicWord) {
		picWordMapper.update(PicWord);
	}

	public PicWordMapper getPicWordMapper() {
		return picWordMapper;
	}

	public void setPicWordMapper(PicWordMapper PicWordMapper) {
		this.picWordMapper = PicWordMapper;
	}
	
	
	

}
